package kn.pulldata.common;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class UrlRotator {
    private final List<String> urls;
    private final AtomicInteger currentIndex = new AtomicInteger(0);

    public UrlRotator(List<String> urls) {
        this.urls = urls;
    }

    public String getNextUrl() {
        int index = currentIndex.getAndUpdate(i -> (i + 1) % urls.size());
        return urls.get(index);
    }
}
